#include <STC15F2K60S2.H>
#include <INTRINS.H>
#include <DELAY.H>

//引脚定义

sbit ADC_DIN=P4^0;
sbit ADC_DOUT=P4^1;
sbit ADC_DCLK=P4^2;
sbit ADC_CS=P4^3;



unsigned int Data=0;

unsigned int ADC_ReadAD(unsigned char Command)
{
	unsigned char i;
	
	Data=0;
	ADC_DCLK=1;
	ADC_CS=1;
	Delay1us(10);
	ADC_CS=0;
	
  Delay1us(10);
	for(i=0;i<4;i++)
	{
		ADC_DCLK=0;
		ADC_DIN=Command&(0x8>>i);
		Delay1us(10);
		ADC_DCLK=1;
	}
	
	for(i=0;i<12;i++)
	{
		ADC_DCLK=0;
		ADC_DIN=Command&(0x08>>i);
		ADC_DCLK=1;
		if(ADC_DOUT){Data|=(0x800>>i);}
	}
	ADC_CS=1;
  
	return Data;
	
}
